/**
 * 
 */
package apache.zookeeper;

import com.netflix.curator.framework.CuratorFramework;
import com.netflix.curator.framework.CuratorFrameworkFactory;
import com.netflix.curator.framework.recipes.locks.InterProcessMutex;
import com.netflix.curator.retry.RetryOneTime;

/**
 * @author qingyan.maqy
 * 
 */
public class TestShareLock {

	/**
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		String path = "/locks/curatorLock";
		final int TIMEOUT_SECONDS = 5000;

		final CuratorFramework client = CuratorFrameworkFactory.newClient(
				"10.232.36.19:2181", TIMEOUT_SECONDS * 1000,
				TIMEOUT_SECONDS * 1000, new RetryOneTime(1));
		client.start();

		try {
			InterProcessMutex ipm = new InterProcessMutex(client, path);
			ipm.acquire();
			System.out.println("test");
			ipm.release();
		} finally {
			if (client != null)
				client.close();
		}

	}

}
